<?php

class YuyueAction extends CommonAction {

	public function index()
	{
		$this->display();
	}
	public function data()
	{
		$r = new RoleModel();
		switch($_POST['do'])
		{
			case 'usercity':
				R("City","data");
				break;
			case 'userbinzhong':
				R('Binzhong','data');
				break;
			case 'roleid':
				echo json_encode($r->field('name,id')->select());
				break;
			default:
				echo $r->getlist('*',$_POST['page'],$_POST['limit']);
			break;
		}

	}

	public function add() {
		if($this->isPost())
		{
			$yObj = D('yuyue');
			$method = $_POST;
			$data = array();
			$data['ipaddr'] = $method['ipaddr'];
			$data['city'] = $method['city'];
			$data['gopage'] = $method['gopage'];
			$data['askpage'] = $method['askpage'];
			$data['keyword'] = $method['keyword'];
			$data['binzhong'] = $method['binzhong'];
			$data['asker'] = $method['asker'];
			$data['askway'] = $method['askway'];
			$data['qq'] = $method['qq'];
			$data['yuyueid'] = $method['yuyueid'];
			$data['name'] = $method['name'];
			$data['proxyer'] = $method['proxyer'];
			$data['phone'] = $method['phone'];
			$data['year'] = $method['year'];
			$data['proficient'] = $method['proficient'];
			$data['starttime'] = strtotime($method['starttime']);
			$data['endtime'] = strtotime($method['endtime']);
			$data['Medicalnumber'] = $method['Medicalnumber'];
			$data['Clinicaltime'] = strtotime($method['Clinicaltime']);
			$data['visit'] = $method['visit'];
			$data['comment'] = $method['comment'];
			$data['date'] = time();
			$data['status'] = 1;
			$data['uid'] = Session::get(C('USER_AUTH_KEY'));
			foreach($data as $k=>$v){
				if($v == NULL) unset($data[$k]);
			}
			if($yObj->add($data))
			{
				$this->success('添加成功');
			}
			else
			{
				$this->error('添加失败');
			}
		}
	}
	public function edit() {
		if($this->isPost())
		{
			$method = $_POST;
			$data = array();
		}
	}
	public function delete() {

	}

}